names(rigal_trends) <- var_temporal_trends
slope <- map_dfr(rigal_trends, ~.x %>%
select(siteid, linear_slope),
.id = "response"
)
slope_df <- slope %>%
pivot_wider(names_from = "response", values_from = "linear_slope")
Check trends
summary_slope <- slope %>%
group_by(response) %>%
summarise(summ = list(enframe(summary_distribution(linear_slope, na.rm = TRUE)))) %>%
unnest(cols = summ) %>%
pivot_wider(names_from = "name", values_from = "value")
summary_slope %>%
mutate(response = get_var_replacement()[response]) %>%
kable() %>%
kable_styling(bootstrap_options = c("striped", "bordered", "hover"))
|
response
|
min
|
1st_quart
|
median
|
2nd_quart
|
max
|
mean
|
sd
|
n
|
n_na
|
frac_na
|
|
Appearance
|
-0.0559441
|
-0.0018271
|
0.0009691
|
0.0065140
|
0.0600000
|
0.0027393
|
0.0098864
|
2678
|
0
|
0
|
|
Chao
|
-0.0975818
|
-0.0105013
|
-0.0015503
|
0.0006336
|
0.1177589
|
-0.0055673
|
0.0155877
|
2678
|
0
|
0
|
|
Chao evenness
|
-1.0762433
|
-0.0197209
|
0.0000000
|
0.0214427
|
0.8698342
|
0.0000118
|
0.0687473
|
2678
|
0
|
0
|
|
Chao species richness
|
-1.0804000
|
-0.0363727
|
0.0002926
|
0.0473422
|
0.9908720
|
0.0073944
|
0.1387268
|
2678
|
0
|
0
|
|
Chao shannon
|
-0.7782364
|
-0.0270535
|
0.0007389
|
0.0362457
|
0.7822804
|
0.0043759
|
0.0822483
|
2678
|
0
|
0
|
|
Chao simpson
|
-0.6747701
|
-0.0241523
|
0.0007189
|
0.0304959
|
0.5440252
|
0.0028965
|
0.0691378
|
2678
|
0
|
0
|
|
Disappearance
|
-0.0486529
|
-0.0005100
|
0.0000000
|
0.0042135
|
0.0557576
|
0.0017718
|
0.0071868
|
2678
|
0
|
0
|
|
Evenness
|
-0.0830806
|
-0.0060849
|
0.0000000
|
0.0069975
|
0.0817728
|
0.0006221
|
0.0144629
|
2678
|
0
|
0
|
|
Turnover abundance
|
-0.1059755
|
-0.0146337
|
-0.0032189
|
0.0007927
|
0.1169447
|
-0.0072135
|
0.0183244
|
2678
|
0
|
0
|
|
Horn
|
-0.0900632
|
-0.0125663
|
-0.0022471
|
0.0006332
|
0.0958701
|
-0.0064480
|
0.0169154
|
2678
|
0
|
0
|
|
Jaccard
|
-0.0931698
|
-0.0118699
|
-0.0045654
|
0.0011438
|
0.0548771
|
-0.0056807
|
0.0130380
|
2678
|
0
|
0
|
|
Log species richness
|
-0.2307581
|
-0.0094470
|
0.0004979
|
0.0139823
|
0.2389473
|
0.0025976
|
0.0262344
|
2678
|
0
|
0
|
|
Log total abundance
|
-0.3751466
|
-0.0284703
|
0.0049807
|
0.0409316
|
0.4436236
|
0.0060785
|
0.0656325
|
2678
|
0
|
0
|
|
Shannon
|
-0.2007711
|
-0.0088851
|
0.0004650
|
0.0121768
|
0.1574411
|
0.0016449
|
0.0221596
|
2678
|
0
|
0
|
|
Simpson
|
-0.0829149
|
-0.0045179
|
0.0001071
|
0.0058510
|
0.0800458
|
0.0007642
|
0.0111222
|
2678
|
0
|
0
|
|
Species richness
|
-1.6727273
|
-0.0328546
|
0.0020269
|
0.0536209
|
1.5727273
|
0.0148247
|
0.1422215
|
2678
|
0
|
0
|
|
Total turnover
|
-0.0559441
|
-0.0013253
|
0.0032257
|
0.0097964
|
0.0621302
|
0.0045111
|
0.0115567
|
2678
|
0
|
0
|
|
Total abundance
|
-755.8336538
|
-1.8770744
|
0.1129827
|
2.2456287
|
398.4499936
|
1.7786740
|
31.5332673
|
2678
|
0
|
0
|
na_siteid_slope <- unique(slope[is.na(slope$linear_slope), ]$siteid)
sd_num <- analysis_dataset %>%
group_by(siteid) %>%
summarise(across(where(is.numeric), ~(sd(.x))))
sd_num %>%
filter(siteid %in% na_siteid_slope) %>%
summary(.)
#> siteid species_nb total_abundance log_total_abundance
#> Length:0 Min. : NA Min. : NA Min. : NA
#> Class :character 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA
#> Mode :character Median : NA Median : NA Median : NA
#> Mean :NaN Mean :NaN Mean :NaN
#> 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA
#> Max. : NA Max. : NA Max. : NA
#> log_species_nb year latitude longitude main_bas
#> Min. : NA Min. : NA Min. : NA Min. : NA Min. : NA
#> 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA
#> Median : NA Median : NA Median : NA Median : NA Median : NA
#> Mean :NaN Mean :NaN Mean :NaN Mean :NaN Mean :NaN
#> 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA
#> Max. : NA Max. : NA Max. : NA Max. : NA Max. : NA
#> chao_richness chao_shannon chao_simpson chao_evenness hillebrand
#> Min. : NA Min. : NA Min. : NA Min. : NA Min. : NA
#> 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA
#> Median : NA Median : NA Median : NA Median : NA Median : NA
#> Mean :NaN Mean :NaN Mean :NaN Mean :NaN Mean :NaN
#> 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA
#> Max. : NA Max. : NA Max. : NA Max. : NA Max. : NA
#> total appearance disappearance jaccard horn
#> Min. : NA Min. : NA Min. : NA Min. : NA Min. : NA
#> 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA
#> Median : NA Median : NA Median : NA Median : NA Median : NA
#> Mean :NaN Mean :NaN Mean :NaN Mean :NaN Mean :NaN
#> 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA
#> Max. : NA Max. : NA Max. : NA Max. : NA Max. : NA
#> chao total_abundance_int shannon simpson inv_simpson
#> Min. : NA Min. : NA Min. : NA Min. : NA Min. : NA
#> 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA
#> Median : NA Median : NA Median : NA Median : NA Median : NA
#> Mean :NaN Mean :NaN Mean :NaN Mean :NaN Mean :NaN
#> 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA
#> Max. : NA Max. : NA Max. : NA Max. : NA Max. : NA
#> evenness first_year last_year span
#> Min. : NA Min. : NA Min. : NA Min. : NA
#> 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA 1st Qu.: NA
#> Median : NA Median : NA Median : NA Median : NA
#> Mean :NaN Mean :NaN Mean :NaN Mean :NaN
#> 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA
#> Max. : NA Max. : NA Max. : NA Max. : NA
- Tremendous trends in abundance:
high_abundance_slope <- slope_df %>%
arrange(desc(abs(total_abundance)))
high_abundance_slope
#> # A tibble: 2,678 × 19
#> siteid total_abundance log_total_abundance species_nb log_species_nb
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 S11735 -756. -0.00976 0.245 0.0130
#> 2 S6466 -472. -0.0773 0.309 0.0137
#> 3 S5180 398. 0.0383 0.207 0.00819
#> 4 S5812 -368. 0.0122 0.393 0.0155
#> 5 S3863 330. 0.119 0.206 0.0152
#> 6 S1787 277. 0.257 0.337 0.0266
#> 7 S8577 256. 0.0467 0.168 0.00797
#> 8 S4501 255. 0.258 0.582 0.102
#> 9 S8158 -249. -0.0658 0.108 0.00560
#> 10 S6074 245. 0.0235 0.198 0.00904
#> # … with 2,668 more rows, and 14 more variables: chao_richness <dbl>,
#> # chao_shannon <dbl>, chao_simpson <dbl>, chao_evenness <dbl>, jaccard <dbl>,
#> # horn <dbl>, chao <dbl>, hillebrand <dbl>, total <dbl>, appearance <dbl>,
#> # disappearance <dbl>, evenness <dbl>, shannon <dbl>, simpson <dbl>
site_desc_slope_total_abundance <-
high_abundance_slope %>%
.[["siteid"]]
- The most tremendous temporal trends in abundance are located in
Illinois and France
ti <- filtered_dataset$location %>%
filter(siteid %in% site_desc_slope_total_abundance[1:20]) %>%
st_as_sf(coords = c("longitude", "latitude"), crs = 2154)
sp::plot(ne_countries())
sp::plot(st_geometry(ti), add = TRUE, col = "red", pch = 19)

filtered_dataset$abun_rich_op %>%
filter(siteid %in% site_desc_slope_total_abundance[1:20]) %>%
group_by(siteid) %>%
summarise(across(c("total_abundance", "species_nb"), list(median = median, mean = mean)))
#> # A tibble: 20 × 5
#> siteid total_abundance_me… total_abundance_… species_nb_medi… species_nb_mean
#> * <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 S11735 5948 17416. 18 18.7
#> 2 S1507 86 698. 2 10.4
#> 3 S1787 2790. 2498. 16.5 15.7
#> 4 S2595 882 1306. 15 15.9
#> 5 S3445 1791 2112. 5.5 5.31
#> 6 S3863 1827 3353. 13 13.6
#> 7 S3883 755 1842. 10 9.46
#> 8 S4325 644. 899. 5.5 5.58
#> 9 S4501 2111 1924. 16 14.9
#> 10 S4755 2517 2335. 20 20.1
#> 11 S5180 4335 8431. 23 23.3
#> 12 S5392 1416 4011. 19.5 18.9
#> 13 S5812 4968 12216. 24.5 25.2
#> 14 S5987 1470 1630. 18 14.2
#> 15 S6074 5908. 9804. 23.5 23.1
#> 16 S6466 3166 6465. 27 25.7
#> 17 S8158 3610 5140. 24.5 24.7
#> 18 S8577 4474 7435. 28 26.4
#> 19 S8852 4126 5016. 25 22.8
#> 20 S9031 3078 11660. 22 22.2
p_high_slope_abun <- map(site_desc_slope_total_abundance[1:20],
~plot_community_data(
analysis_dataset %>%
filter(siteid == .x) %>%
select(siteid, year, total_abundance),
y = "total_abundance", x = "year",
smoothing_method = "lm"))
plot_grid(plotlist = p_high_slope_abun, ncol = 3)

s11735_com <- analysis_dataset %>%
filter(siteid == site_desc_slope_total_abundance[1]) %>%
arrange(year) %>%
select(siteid, year, total_abundance)
s11735_com
#> # A tibble: 25 × 3
#> siteid year total_abundance
#> <chr> <dbl> <dbl>
#> 1 S11735 1993 66
#> 2 S11735 1994 1366
#> 3 S11735 1995 109088
#> 4 S11735 1996 9997
#> 5 S11735 1997 512
#> 6 S11735 1998 5948
#> 7 S11735 1999 85163
#> 8 S11735 2000 10785
#> 9 S11735 2001 21720
#> 10 S11735 2002 11719
#> # … with 15 more rows
plot_community_data(s11735_com, y = "total_abundance", x = "year",
smoothing_method = "lm")

mean(s11735_com$total_abundance) - sd(s11735_com$total_abundance)
#> [1] -10662.47
mean(s11735_com$total_abundance) + 5 * sd(s11735_com$total_abundance)
#> [1] 157805.5
s11735_pop <- filtered_dataset$measurement %>%
filter(siteid == site_desc_slope_total_abundance[1]) %>%
arrange(year) %>%
select(siteid, year, species, abundance)
s11735_pop %>%
group_by(species) %>%
summarise(abun = sum(abundance)) %>%
arrange(desc(abun))
#> # A tibble: 52 × 2
#> species abun
#> <chr> <dbl>
#> 1 Notropis atherinoides 418706
#> 2 Notropis volucellus 8400
#> 3 Cyprinella spiloptera 1949
#> 4 Lepomis macrochirus 1659
#> 5 Dorosoma cepedianum 651
#> 6 Aplodinotus grunniens 614
#> 7 Morone chrysops 540
#> 8 Pimephales vigilax 527
#> 9 Cyprinus carpio 427
#> 10 Macrhybopsis aestivalis 386
#> # … with 42 more rows
plot_temporal_population(s11735_pop) +
theme(legend.position = "bottom")
#> Note: Using an external vector in selections is ambiguous.
#> ℹ Use `all_of(species_var)` instead of `species_var` to silence this message.
#> ℹ See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
#> This message is displayed once per session.
#> Note: Using an external vector in selections is ambiguous.
#> ℹ Use `all_of(y_var)` instead of `y_var` to silence this message.
#> ℹ See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
#> This message is displayed once per session.
#> Note: Using an external vector in selections is ambiguous.
#> ℹ Use `all_of(species)` instead of `species` to silence this message.
#> ℹ See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
#> This message is displayed once per session.
#> Warning: Removed 52 rows containing missing values (position_stack).

s6466_com <- analysis_dataset %>%
filter(siteid == site_desc_slope_total_abundance[2]) %>%
arrange(year) %>%
select(siteid, year, total_abundance)
s6466_com
#> # A tibble: 11 × 3
#> siteid year total_abundance
#> <chr> <dbl> <dbl>
#> 1 S6466 1981 7844
#> 2 S6466 1983 11938
#> 3 S6466 1987 9521
#> 4 S6466 1988 23997
#> 5 S6466 1989 1558
#> 6 S6466 1990 1674
#> 7 S6466 1991 3166
#> 8 S6466 1992 862
#> 9 S6466 1997 2687
#> 10 S6466 1999 1558
#> 11 S6466 2000 6314
plot_community_data(s6466_com, y = "total_abundance", x = "year",
smoothing_method = "lm")

Relationships among temporal trends
cor_slope <- slope_df %>%
select(-siteid) %>%
cor(., method = "spearman")
cor_slope
#> total_abundance log_total_abundance species_nb
#> total_abundance 1.00000000 0.830317697 0.277156569
#> log_total_abundance 0.83031770 1.000000000 0.335207093
#> species_nb 0.27715657 0.335207093 1.000000000
#> log_species_nb 0.24998531 0.341425460 0.938124340
#> chao_richness 0.01669974 0.078327544 0.815025195
#> chao_shannon -0.06097157 -0.004315524 0.598119627
#> chao_simpson -0.06860767 -0.030703462 0.486160737
#> chao_evenness -0.04633317 0.001842386 0.158532100
#> jaccard -0.03478444 0.025685809 0.008257763
#> horn 0.04662609 0.094698554 -0.012567803
#> chao 0.08061120 0.137592452 -0.017802771
#> hillebrand 0.04956023 0.095796198 -0.025148726
#> total 0.02062614 0.011421991 0.205181084
#> appearance 0.16165086 0.192922044 0.687912675
#> disappearance -0.16107870 -0.222194738 -0.555815437
#> evenness -0.13546800 -0.106903064 0.191546294
#> shannon -0.03065257 0.031284774 0.595797755
#> simpson -0.03676218 0.012861550 0.475730622
#> log_species_nb chao_richness chao_shannon chao_simpson
#> total_abundance 0.249985313 0.01669974 -0.060971568 -0.068607673
#> log_total_abundance 0.341425460 0.07832754 -0.004315524 -0.030703462
#> species_nb 0.938124340 0.81502519 0.598119627 0.486160737
#> log_species_nb 1.000000000 0.79177797 0.652155915 0.557993783
#> chao_richness 0.791777969 1.00000000 0.715598168 0.585062363
#> chao_shannon 0.652155915 0.71559817 1.000000000 0.944296056
#> chao_simpson 0.557993783 0.58506236 0.944296056 1.000000000
#> chao_evenness 0.238535129 0.17861100 0.627245251 0.673326844
#> jaccard 0.015124583 0.02328089 0.017092770 0.001769782
#> horn -0.004627739 -0.01798976 -0.041646520 -0.055713026
#> chao 0.001700015 -0.05100309 -0.070761250 -0.087567081
#> hillebrand -0.021932729 -0.03353840 -0.068107966 -0.083243368
#> total 0.197785326 0.18733040 0.126450573 0.112381282
#> appearance 0.691339427 0.58925101 0.453612568 0.384514986
#> disappearance -0.577830666 -0.45943156 -0.378710413 -0.308701065
#> evenness 0.290015512 0.32190903 0.722795822 0.778140322
#> shannon 0.652776243 0.67989789 0.944628419 0.911228727
#> simpson 0.555099300 0.55478316 0.873409696 0.891031340
#> chao_evenness jaccard horn chao
#> total_abundance -0.046333174 -0.034784436 0.046626092 0.080611195
#> log_total_abundance 0.001842386 0.025685809 0.094698554 0.137592452
#> species_nb 0.158532100 0.008257763 -0.012567803 -0.017802771
#> log_species_nb 0.238535129 0.015124583 -0.004627739 0.001700015
#> chao_richness 0.178610995 0.023280895 -0.017989761 -0.051003088
#> chao_shannon 0.627245251 0.017092770 -0.041646520 -0.070761250
#> chao_simpson 0.673326844 0.001769782 -0.055713026 -0.087567081
#> chao_evenness 1.000000000 0.069726825 0.032975571 0.039982689
#> jaccard 0.069726825 1.000000000 0.535041875 0.360518080
#> horn 0.032975571 0.535041875 1.000000000 0.633224505
#> chao 0.039982689 0.360518080 0.633224505 1.000000000
#> hillebrand 0.014641849 0.543277340 0.989087254 0.615220619
#> total -0.042854829 -0.255210721 -0.316495191 -0.589439704
#> appearance 0.090571956 -0.140290491 -0.201907697 -0.347493182
#> disappearance -0.143240688 -0.200173498 -0.225399007 -0.445526259
#> evenness 0.712515794 0.028733429 -0.023213578 -0.037192382
#> shannon 0.565547657 0.010823334 -0.044699272 -0.079869118
#> simpson 0.595960699 0.013305625 -0.042511617 -0.075603823
#> hillebrand total appearance disappearance
#> total_abundance 0.04956023 0.02062614 0.16165086 -0.1610787
#> log_total_abundance 0.09579620 0.01142199 0.19292204 -0.2221947
#> species_nb -0.02514873 0.20518108 0.68791268 -0.5558154
#> log_species_nb -0.02193273 0.19778533 0.69133943 -0.5778307
#> chao_richness -0.03353840 0.18733040 0.58925101 -0.4594316
#> chao_shannon -0.06810797 0.12645057 0.45361257 -0.3787104
#> chao_simpson -0.08324337 0.11238128 0.38451499 -0.3087011
#> chao_evenness 0.01464185 -0.04285483 0.09057196 -0.1432407
#> jaccard 0.54327734 -0.25521072 -0.14029049 -0.2001735
#> horn 0.98908725 -0.31649519 -0.20190770 -0.2253990
#> chao 0.61522062 -0.58943970 -0.34749318 -0.4455263
#> hillebrand 1.00000000 -0.31748997 -0.21212267 -0.2067202
#> total -0.31748997 1.00000000 0.72528811 0.4888940
#> appearance -0.21212267 0.72528811 1.00000000 -0.1164785
#> disappearance -0.20672017 0.48889404 -0.11647853 1.0000000
#> evenness -0.05321078 -0.01433782 0.13964393 -0.1757330
#> shannon -0.07563072 0.11786971 0.44713913 -0.3873377
#> simpson -0.07581108 0.08965621 0.36745811 -0.3224297
#> evenness shannon simpson
#> total_abundance -0.13546800 -0.03065257 -0.03676218
#> log_total_abundance -0.10690306 0.03128477 0.01286155
#> species_nb 0.19154629 0.59579776 0.47573062
#> log_species_nb 0.29001551 0.65277624 0.55509930
#> chao_richness 0.32190903 0.67989789 0.55478316
#> chao_shannon 0.72279582 0.94462842 0.87340970
#> chao_simpson 0.77814032 0.91122873 0.89103134
#> chao_evenness 0.71251579 0.56554766 0.59596070
#> jaccard 0.02873343 0.01082333 0.01330562
#> horn -0.02321358 -0.04469927 -0.04251162
#> chao -0.03719238 -0.07986912 -0.07560382
#> hillebrand -0.05321078 -0.07563072 -0.07581108
#> total -0.01433782 0.11786971 0.08965621
#> appearance 0.13964393 0.44713913 0.36745811
#> disappearance -0.17573304 -0.38733767 -0.32242970
#> evenness 1.00000000 0.78404775 0.86697732
#> shannon 0.78404775 1.00000000 0.96231642
#> simpson 0.86697732 0.96231642 1.00000000
png(here("doc", "fig", "p_cor_slope.png"))
corrplot::corrplot(cor_slope[c("chao_richness", "species_nb", "log_species_nb",
"total_abundance", "log_total_abundance"), ], type = "upper", tl.srt = 45, diag = FALSE)
dev.off()
#> png
#> 2
png(here("doc", "fig", "p_cor_slope_tot.png"))
corrplot::corrplot(cor_slope, type = "upper", tl.srt = 35, diag = FALSE)
dev.off()
#> png
#> 2
corrplot::corrplot(cor_slope[c("chao_richness", "species_nb", "log_species_nb",
"total_abundance", "log_total_abundance"), ], type = "upper", tl.srt = 45, diag = FALSE)

corrplot::corrplot(cor_slope, type = "upper", tl.srt = 35, diag = FALSE)

ti <- expand.grid(
resp1 = unique(slope$response),
resp2 = unique(slope$response)
) %>%
filter(resp2 != resp1) %>%
filter(
resp1 %in% c("chao_richness", "species_nb", "log_species_nb",
"total_abundance", "log_total_abundance")) %>%
mutate_all(as.character) %>%
arrange(resp1)
test <- map2(ti$resp1, ti$resp2,
function(x, y) {
bi <- slope %>%
filter(response %in% c(x, y)) %>%
select(siteid, response, linear_slope) %>%
pivot_wider(names_from = "response", values_from = "linear_slope")
return(bi)
}
)
p <- map(test, function(x) {
l <- colnames(x)
x %>%
ggplot(aes(x = !!sym(l[2]), y = !!sym(l[3]))) +
geom_point() +
geom_smooth(method = "lm") +
labs(
x = get_var_replacement()[l[2]],
y = get_var_replacement()[l[3]]
)
})
names(p) <- map_chr(test, ~colnames(.x)[2])
plot_grid(plotlist = p[names(p) %in% "total_abundance"], ncol = 3)
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'

plot_grid(plotlist = p[names(p) %in% "species_nb"], ncol = 3)
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'

plot_grid(plotlist = p[names(p) %in% "log_species_nb"], ncol = 3)
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'
#> `geom_smooth()` using formula 'y ~ x'

- Trends of total abundance are linked to the one of species richness but not to
shannon and simpson, suggesting that the trends of abundance are more link to
trends of rare species. Logic: gain and loss of species should concern rare
species.
p <- map2(rigal_trends, names(rigal_trends),
~.x %>%
ggplot(aes(x = linear_slope)) +
geom_histogram() +
labs(title = .y)
)
plot_grid(plotlist = p)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Look at strong turnover trends
high_jaccard_slope <-
slope_df %>%
select(siteid, total_abundance, species_nb, jaccard) %>%
arrange(desc(jaccard))
high_jaccard_slope
#> # A tibble: 2,678 × 4
#> siteid total_abundance species_nb jaccard
#> <chr> <dbl> <dbl> <dbl>
#> 1 S2412 -0.683 0 0.0549
#> 2 S7492 0.205 -4.20e- 2 0.0494
#> 3 S81 5.27 -5.45e- 2 0.0463
#> 4 S1442 -21.1 1.94e- 1 0.0455
#> 5 S1451 -0.175 -2.42e- 2 0.0450
#> 6 S6303 -2.01 0 0.0448
#> 7 S4285 3.35 -2.22e- 2 0.0421
#> 8 S1010 -0.483 -2.38e- 2 0.0420
#> 9 S2613 -6.51 -2.60e- 2 0.0386
#> 10 S869 -3.11 -5.92e-17 0.0376
#> # … with 2,668 more rows
site_desc_jaccard_slope <-
high_jaccard_slope %>%
.[["siteid"]]
ti <- filtered_dataset$location %>%
filter(siteid %in% site_desc_jaccard_slope[1:20]) %>%
st_as_sf(coords = c("longitude", "latitude"), crs = 2154)
sp::plot(ne_countries())
sp::plot(st_geometry(ti), add = TRUE, col = "red", pch = 19)

filtered_dataset$abun_rich_op %>%
filter(siteid %in% site_desc_jaccard_slope[1:20]) %>%
group_by(siteid) %>%
summarise(across(c("total_abundance", "species_nb"),
list(median = median, mean = mean))) %>%
kable() %>%
kable_styling(bootstrap_options = c("striped", "bordered", "hover")) %>%
scroll_box(width = "100%", height = "400px")
|
siteid
|
total_abundance_median
|
total_abundance_mean
|
species_nb_median
|
species_nb_mean
|
|
S1010
|
17.600
|
23.900000
|
2.0
|
2.454546
|
|
S1151
|
1214.000
|
1278.500000
|
12.0
|
11.750000
|
|
S1442
|
178.500
|
278.400000
|
8.0
|
8.000000
|
|
S1451
|
17.000
|
16.200000
|
2.0
|
2.500000
|
|
S2102
|
40.350
|
49.300000
|
2.0
|
1.916667
|
|
S2412
|
12.500
|
14.200000
|
1.0
|
1.000000
|
|
S2613
|
103.500
|
108.834600
|
3.0
|
2.900000
|
|
S4285
|
92.900
|
120.900000
|
1.0
|
1.066667
|
|
S6013
|
96.500
|
105.700000
|
8.0
|
8.400000
|
|
S6303
|
40.050
|
39.600000
|
1.0
|
1.000000
|
|
S6550
|
6.650
|
14.557143
|
2.0
|
2.214286
|
|
S6868
|
57.927
|
66.733364
|
2.0
|
1.636364
|
|
S7036
|
27.600
|
31.958333
|
2.0
|
1.666667
|
|
S7329
|
44.000
|
44.237500
|
3.0
|
3.250000
|
|
S7421
|
10.500
|
9.835294
|
3.0
|
2.764706
|
|
S7492
|
6.450
|
8.025000
|
2.5
|
2.333333
|
|
S7805
|
12.950
|
24.916667
|
1.5
|
1.500000
|
|
S81
|
75.000
|
73.636364
|
2.0
|
2.363636
|
|
S8567
|
103.000
|
128.266667
|
4.0
|
4.400000
|
|
S869
|
38.250
|
40.225000
|
1.0
|
1.000000
|
p_high_jaccard_slope <- map(site_desc_jaccard_slope[1:20],
~plot_community_data(
analysis_dataset %>%
filter(siteid == .x) %>%
select(siteid, year, jaccard),
y = "jaccard", x = "year",
smoothing_method = "lm"))
plot_grid(plotlist = p_high_jaccard_slope, ncol = 3)
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).

tar_load(vegdist_turnover_c)
- Hum, do not understand why community are more similar at the end of the time-steps
p_pop_high_jaccard <-
map(site_desc_jaccard_slope[1:20],
~plot_temporal_population(
filtered_dataset$measurement %>%
filter(siteid == .x)
) +
theme(legend.position = "none")
)
plot_grid(plotlist = p_pop_high_jaccard, ncol = 3)
#> Warning: Removed 2 rows containing missing values (position_stack).
#> Warning: Removed 49 rows containing missing values (position_stack).
#> Warning: Removed 2 rows containing missing values (position_stack).
#> Warning: Removed 8 rows containing missing values (position_stack).
#> Warning: Removed 4 rows containing missing values (position_stack).
#> Warning: Removed 3 rows containing missing values (position_stack).
#> Warning: Removed 6 rows containing missing values (position_stack).
#> Warning: Removed 22 rows containing missing values (position_stack).
#> Warning: Removed 51 rows containing missing values (position_stack).
#> Warning: Removed 27 rows containing missing values (position_stack).
#> Warning: Removed 24 rows containing missing values (position_stack).
#> Warning: Removed 26 rows containing missing values (position_stack).
#> Warning: Removed 4 rows containing missing values (position_stack).
#> Warning: Removed 48 rows containing missing values (position_stack).

- Lets see communities that becomes more dissimilar:
p_jaccard_low_jaccard <-
map(site_desc_jaccard_slope[(length(site_desc_jaccard_slope)-20):length(site_desc_jaccard_slope)],
~plot_community_data(
analysis_dataset %>%
filter(siteid == .x) %>%
select(siteid, year, jaccard),
y = "jaccard", x = "year",
smoothing_method = "lm"))
plot_grid(plotlist = p_jaccard_low_jaccard, ncol = 3)
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).

p_pop_low_jaccard <-
map(site_desc_jaccard_slope[
(length(site_desc_jaccard_slope)-20):length(site_desc_jaccard_slope)],
~plot_temporal_population(
filtered_dataset$measurement %>%
filter(siteid == .x)
) +
theme(legend.position = "none")
)
plot_grid(plotlist = p_pop_low_jaccard, ncol = 3)
#> Warning: Removed 32 rows containing missing values (position_stack).
#> Warning: Removed 40 rows containing missing values (position_stack).
#> Warning: Removed 36 rows containing missing values (position_stack).
#> Warning: Removed 21 rows containing missing values (position_stack).
#> Warning: Removed 18 rows containing missing values (position_stack).
#> Warning: Removed 21 rows containing missing values (position_stack).
#> Warning: Removed 10 rows containing missing values (position_stack).
#> Warning: Removed 25 rows containing missing values (position_stack).
#> Warning: Removed 2 rows containing missing values (position_stack).
#> Warning: Removed 24 rows containing missing values (position_stack).
#> Warning: Removed 63 rows containing missing values (position_stack).

Comparison rigal, lm
rigal_trends_df <- map2_dfr(
rigal_trends, names(rigal_trends),
~.x %>% mutate(variable = .y)
) %>%
select(variable, siteid, linear_slope) %>%
pivot_wider(names_from = "variable", values_from = "linear_slope") %>%
mutate(type = "rigal")
slope_comp <- list()
slope_comp$rigal <- rigal_trends_df[order(rigal_trends_df$siteid), ]
slope_comp$simple_lm <- slope_df[order(slope_df$siteid), ]
stopifnot(all(slope_comp$rigal$siteid == slope_comp$simple_lm$siteid))
slope_comp$diff <- tibble(
siteid = slope_comp$rigal$siteid)
for (i in var_temporal_trends) {
slope_comp$diff[[i]] <- slope_comp$rigal[[i]] - slope_comp$simple_lm[[i]]
}
old_par <- par()
par(mfrow = c(3, 2))
for (i in var_temporal_trends) {
plot(
slope_comp$rigal[[i]] ~
slope_comp$simple_lm[[i]],
ylab = "Rigal (polynomial degree 2)",
xlab = "Simple LM"
)
abline(0, 1)
title(i)
}



par(old_par)
#> Warning in par(old_par): le paramètre graphique "cin" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "cra" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "csi" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "cxy" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "din" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "page" ne peut être changé
# Compare Rigal and simple lm for few sites
plot_rigal_raw_data <- function(
site = NULL,
response = NULL,
dataset = NULL,
rigal_trends = NULL
) {
raw_data <- dataset %>%
filter(siteid == site)
rigal_resp <- rigal_trends[[response]]
rigal_resp_site <- rigal_resp[rigal_resp$siteid == site, ]
plot(raw_data[[response]]~raw_data[["year"]], ylab = response, xlab = "Year")
abline(rigal_resp_site$intercept, rigal_resp_site$linear_slope, col
= "red")
abline(lm(raw_data[[response]]~raw_data[["year"]]), col = "green")
title(main = site)
}
plot_rigal_raw_data(site = "S2672", response = "log_total_abundance", dataset =
analysis_dataset, rigal_trends = rigal_trends)

slope_comp$diff <- slope_comp$diff %>%
arrange(desc(abs(log_total_abundance)))
old_par <- par()
par(mfrow = c(3, 2))
for (i in slope_comp$diff[1:6,]$siteid) {
plot_rigal_raw_data(
site = i,
response = "log_total_abundance",
dataset = analysis_dataset,
rigal_trends = rigal_trends
)
}

par(old_par)
#> Warning in par(old_par): le paramètre graphique "cin" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "cra" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "csi" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "cxy" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "din" ne peut être changé
#> Warning in par(old_par): le paramètre graphique "page" ne peut être changé
Polynomial
classification_station <- map2(rigal_trends, names(rigal_trends),
~.x %>%
ggplot(aes(x = shape_class)) +
geom_bar() +
labs(x = "Trajectory classification", y = "Nb station",
title = get_var_replacement()[.y]) +
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
)
plot_grid(plotlist = classification_station)

p_classif_abun_rich <- plot_grid(
plotlist = classification_station[
names(classification_station)[str_detect(names(classification_station),
"abundance|richness|species")]])
save_plot(
here("doc", "fig", "classif_trends_abun_rich.png"),
p_classif_abun_rich
)
p_classif_hill_evenness <- plot_grid(
plotlist = classification_station[
names(classification_station)[str_detect(names(classification_station),
"shannon|simpson|evennes")]])
save_plot(
here("doc", "fig", "classif_trends_hill_evenness.png"),
p_classif_hill_evenness
)
p_classif_turnover <- plot_grid(
plotlist = classification_station[
names(classification_station)[names(classification_station) %in%
c("jaccard", "horn", "chao", "hillebrand", "total", "appearance",
"disappearance")]])
save_plot(
here("doc", "fig", "classif_trends_classif_hill_evenness.png"),
p_classif_turnover
)
ti <- map_dfr(rigal_trends, ~tabyl_df(x = .x, group = "direction"),
.id = "response"
)
ti %>%
filter(direction != "Total") %>%
select(response, direction, percent) %>%
pivot_wider(names_from = "direction", values_from = "percent")
#> # A tibble: 18 × 4
#> response stable increase decrease
#> <chr> <chr> <chr> <chr>
#> 1 total_abundance 75.8% 14.3% 9.9%
#> 2 log_total_abundance 73.3% 16.5% 10.2%
#> 3 species_nb 77.7% 13.2% 7.4%
#> 4 log_species_nb 76.2% 13.2% 6.6%
#> 5 chao_richness 79.8% 10.6% 8.2%
#> 6 chao_shannon 76.5% 12.1% 7.7%
#> 7 chao_simpson 78.4% 10.5% 7.4%
#> 8 chao_evenness 82.8% 7.5% 5.9%
#> 9 jaccard 76.0% 3.5% 20.4%
#> 10 horn 75.9% 4.4% 17.6%
#> 11 chao 75.7% 4.0% 17.4%
#> 12 hillebrand 75.3% 4.1% 18.6%
#> 13 total 73.7% 18.3% 3.0%
#> 14 appearance 70.2% 15.6% 3.8%
#> 15 disappearance 64.0% 9.5% 3.0%
#> 16 evenness 78.8% 9.4% 8.1%
#> 17 shannon 75.7% 12.2% 8.3%
#> 18 simpson 77.9% 10.8% 7.7%
#3.3 Log-linear model:logYi=α+βXi+εiIn
#the log-linear model, the literal interpretation of the estimated
#coefficientˆβis that a one-unitincrease inXwill produce an expected increase in
#logYofˆβunits.
#In terms ofYitself, this
#meansthat the expected value ofYis multiplied byeˆβ. So in terms of
#effects of changes inXonY(unlogged):•Each 1-unit increase inXmultiplies the
#expected value ofYbyeˆβ.•To compute the effects onYof another change inXthan an
#increase of one unit, call thischangec, we need to includecin the exponent. The
#effect of ac-unit increase inXis tomultiply the expected value ofYbyecˆβ. So the
#effect for a 5-unit increase inXwould bee5ˆβ.•For small values ofˆβ,
#approximatelyeˆβ≈1+ˆβ. We can use this for the following approxima-tion for a
#quick interpretation of the coefficients: 100·ˆβis the expected percentage
#changeinYfor a unit increase inX. For instance forˆβ=.06,e.06≈1.06, so a 1-unit
#change inXcorresponds to (approximately) an expected increase inYof 6%
#https://data.library.virginia.edu/interpreting-log-transformations-in-a-linear-model/
hist_linear_plot <- map2(rigal_trends, names(rigal_trends),
~.x %>%
ggplot(aes(x = linear_slope)) +
geom_histogram() +
labs(x = "Linear slope", y = "Number of station",
title = get_var_replacement()[.y]) +
ylim(c(0, 1000))
)
plot_grid(plotlist = hist_linear_plot)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

type_response <- list(
abun_rich = str_detect(names(classification_station),
"abundance|richness|species"),
hill_evenness = str_detect(names(classification_station),
"shannon|simpson|evennes"),
turnover = names(classification_station) %in%
c("jaccard", "horn", "chao", "hillebrand", "total", "appearance",
"disappearance")
)
map2(type_response, names(type_response),
function(x, y) {
p <- plot_grid(
plotlist = hist_linear_plot[
names(hist_linear_plot)[x]
]
)
save_plot(
here("doc", "fig", paste0("hist_linear_slope_", y, ".png")),
p
)
}
)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 1 rows containing missing values (geom_bar).
#> $abun_rich
#> NULL
#>
#> $hill_evenness
#> NULL
#>
#> $turnover
#> NULL
Spatialization of temporal trends
rigal_trends_df_loc <-
rigal_trends_df %>%
left_join(
select(filtered_dataset$location, siteid, ecoregion, country),
by = c("siteid"))
- No obvious geographic patterns
rigal_trends_df_loc %>%
ggplot(aes(x = country, y = log_species_nb, fill = ecoregion)) +
geom_boxplot()

rigal_trends_df_loc %>%
ggplot(aes(x = country, y = log_total_abundance, fill = ecoregion)) +
geom_boxplot()

rigal_trends_df_loc %>%
ggplot(aes(x = country, y = total, fill = ecoregion)) +
geom_boxplot()

rigal_trends_df_loc %>%
ggplot(aes(x = country, y = jaccard, fill = ecoregion)) +
geom_boxplot()

rigal_trends_df %>%
summarise(across(where(is.numeric), median, na.rm = T)) %>%
unlist()
#> total_abundance log_total_abundance species_nb log_species_nb
#> 0.1129827405 0.0049806811 0.0020269075 0.0004978780
#> chao_richness chao_shannon chao_simpson chao_evenness
#> 0.0002926352 0.0007389185 0.0007189205 0.0000000000
#> jaccard horn chao hillebrand
#> -0.0045653921 -0.0022471349 -0.0015502502 -0.0032188608
#> total appearance disappearance evenness
#> 0.0032257174 0.0009691423 0.0000000000 0.0000000000
#> shannon simpson
#> 0.0004650060 0.0001071122
median(exp(rigal_trends_df$log_total_abundance) - 1) * 100
#> [1] 0.4993106
sd(exp(rigal_trends_df$log_total_abundance) - 1) * 100
#> [1] 6.675692
median(exp(na.omit(rigal_trends_df$log_species_nb)) - 1) * 100
#> [1] 0.04980022
sd(exp(na.omit(rigal_trends_df$log_species_nb)) - 1) * 100
#> [1] 2.65351
Analysis
Reproducibility
Reproducibility receipt
## datetime
Sys.time()
#> [1] "2022-01-10 17:38:33 CST"
## repository
if(requireNamespace('git2r', quietly = TRUE)) {
git2r::repository()
} else {
c(
system2("git", args = c("log", "--name-status", "-1"), stdout = TRUE),
system2("git", args = c("remote", "-v"), stdout = TRUE)
)
}
#> Local: main /home/alain/Documents/post-these/isu/RivFishTimeBiodiversityFacets
#> Head: [34e0a3d] 2022-01-10: Compute avg abundance over first years
## session info
sessionInfo()
#> R version 4.0.5 (2021-03-31)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Debian GNU/Linux 10 (buster)
#>
#> Matrix products: default
#> BLAS: /home/alain/.Renv/versions/4.0.5/lib/R/lib/libRblas.so
#> LAPACK: /home/alain/.Renv/versions/4.0.5/lib/R/lib/libRlapack.so
#>
#> locale:
#> [1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8
#> [5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8
#> [7] LC_PAPER=fr_FR.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] untb_1.7-4 future_1.21.0 vegan_2.5-7
#> [4] lattice_0.20-41 permute_0.9-5 codyn_2.0.5
#> [7] janitor_2.1.0 cowplot_1.1.1 rnaturalearthdata_0.1.0
#> [10] rnaturalearth_0.1.0 sf_1.0-4 rmarkdown_2.11
#> [13] scales_1.1.1 kableExtra_1.3.1 here_1.0.1
#> [16] lubridate_1.7.9.2 magrittr_2.0.1 forcats_0.5.1
#> [19] stringr_1.4.0 dplyr_1.0.4 purrr_0.3.4
#> [22] readr_2.1.1 tidyr_1.1.2 tibble_3.1.6
#> [25] ggplot2_3.3.3 tidyverse_1.3.0 tarchetypes_0.3.2
#> [28] targets_0.8.1 conflicted_1.1.0
#>
#> loaded via a namespace (and not attached):
#> [1] colorspace_2.0-0 ellipsis_0.3.2 class_7.3-18 rgdal_1.5-28
#> [5] rprojroot_2.0.2 snakecase_0.11.0 fs_1.5.1 rstudioapi_0.13
#> [9] farver_2.0.3 listenv_0.8.0 fansi_0.5.0 mathjaxr_1.4-0
#> [13] xml2_1.3.2 partitions_1.10-4 codetools_0.2-18 splines_4.0.5
#> [17] cachem_1.0.4 knitr_1.36 polynom_1.4-0 jsonlite_1.7.2
#> [21] broom_0.7.4 cluster_2.1.1 dbplyr_2.1.0 compiler_4.0.5
#> [25] httr_1.4.2 backports_1.2.1 assertthat_0.2.1 Matrix_1.3-2
#> [29] fastmap_1.1.0 cli_3.1.0 htmltools_0.5.1.1 tools_4.0.5
#> [33] gmp_0.6-2.1 igraph_1.2.6 gtable_0.3.0 glue_1.5.1
#> [37] Rcpp_1.0.6 cellranger_1.1.0 jquerylib_0.1.3 vctrs_0.3.8
#> [41] nlme_3.1-152 xfun_0.28 globals_0.14.0 ps_1.6.0
#> [45] rvest_0.3.6 lifecycle_1.0.1 MASS_7.3-53.1 Brobdingnag_1.2-6
#> [49] hms_1.1.1 parallel_4.0.5 yaml_2.2.1 memoise_2.0.0
#> [53] sass_0.3.1 stringi_1.7.6 highr_0.9 corrplot_0.84
#> [57] e1071_1.7-4 rlang_0.4.12 pkgconfig_2.0.3 evaluate_0.14
#> [61] labeling_0.4.2 processx_3.5.2 tidyselect_1.1.1 parallelly_1.23.0
#> [65] bookdown_0.24 R6_2.5.1 generics_0.1.0 DBI_1.1.1
#> [69] pillar_1.6.4 haven_2.3.1 withr_2.4.3 mgcv_1.8-34
#> [73] units_0.6-7 sp_1.4-5 modelr_0.1.8 crayon_1.4.2
#> [77] KernSmooth_2.23-18 utf8_1.2.2 tzdb_0.2.0 grid_4.0.5
#> [81] readxl_1.3.1 data.table_1.13.6 git2r_0.29.0 callr_3.7.0
#> [85] reprex_1.0.0 digest_0.6.27 classInt_0.4-3 webshot_0.5.2
#> [89] munsell_0.5.0 viridisLite_0.3.0 bslib_0.2.4